package com.stylefeng.guns.gateway.modular.vo;

import lombok.Getter;
import lombok.Setter;

/**
 * @auther: madison
 * @date: 2018/11/8 22:41
 * @description:
 */
@Getter
@Setter
public class ResponseVO<M> {
    // 返回信息【0-成功，1-业务失败，999-表示系统异常】
    private int status;
    //返回信息
    private String msg;
    //返回数据实体
    private M data;
    // 图片前缀
    private String imgPre;
    // 分页使用
    private int nowPage;
    private int totalPage;

    private ResponseVO() {
    }

    public static <M> ResponseVO success(int nowPage, int totalPage,String imgPre,M data) {
        ResponseVO responseVO = new ResponseVO();
        responseVO.setStatus(0);
        responseVO.setNowPage(nowPage);
        responseVO.setTotalPage(totalPage);
        responseVO.setImgPre(imgPre);
        responseVO.setData(data);
        return responseVO;
    }

    public static <M> ResponseVO success(String imgPre,M data) {
        ResponseVO responseVO = new ResponseVO();
        responseVO.setStatus(0);
        responseVO.setImgPre(imgPre);
        responseVO.setData(data);
        return responseVO;
    }

    public static <M> ResponseVO success(M data) {
        ResponseVO responseVO = new ResponseVO();
        responseVO.setStatus(0);
        responseVO.setData(data);
        return responseVO;
    }

    public static <M> ResponseVO success(String msg) {
        ResponseVO responseVO = new ResponseVO();
        responseVO.setStatus(0);
        responseVO.setMsg(msg);
        return responseVO;
    }

    public static <M> ResponseVO serviceFail(String msg) {
        ResponseVO responseVO = new ResponseVO();
        responseVO.setStatus(1);
        responseVO.setMsg(msg);
        return responseVO;
    }

    public static <M> ResponseVO appFail(String msg) {
        ResponseVO responseVO = new ResponseVO();
        responseVO.setStatus(999);
        responseVO.setMsg(msg);
        return responseVO;
    }
}
